package com.qys.livesMall.finance.enums;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;

public enum AccountBusinessTypeEnum {

    RECHARGE_APPLY_FOR("re_af","re","RE","用户充值申请",AccountTypeEnum.R_W_ACCOUNT,AccountTypeEnum.ALLOCATION_ACCOUNT,AmountIconEnum.RE),
    RECHARGE_DIFFERENCE("re_de","re","RE","用户充值差额",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.R_W_ACCOUNT,AmountIconEnum.RE),
    RECHARGE("re","re","RE","用户充值",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    RECHARGE_CANCEL("re_cl","re","RE","用户充值取消",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.R_W_ACCOUNT,AmountIconEnum.RE),
    WITHDRAWAL_APPLY_FOR("wl_af","wl","WL","用户提现申请",AccountTypeEnum.USER_ACCOUNT,AccountTypeEnum.ALLOCATION_ACCOUNT,AmountIconEnum.OUT),
    WITHDRAWAL_CANCEL("wl_cl","wl","WL","用户提现取消",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.RE),
    WITHDRAWAL("wl","wl","WL","用户提现",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.R_W_ACCOUNT,AmountIconEnum.OUT),
    SHOP_RECHARGE_APPLY_FOR("sre_af","sre","SRE","店铺充值申请",AccountTypeEnum.R_W_ACCOUNT,AccountTypeEnum.ALLOCATION_ACCOUNT,AmountIconEnum.RE),
    SHOP_RECHARGE_DIFFERENCE("sre_de","sre","SRE","店铺充值差额,实际<申请",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.R_W_ACCOUNT,AmountIconEnum.RE),
    SHOP_RECHARGE("sre","sre","SRE","店铺充值",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.IN),
    SHOP_RECHARGE_CANCEL("sre_cl","sre","SRE","店铺充值取消",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.R_W_ACCOUNT,AmountIconEnum.RE),
    SHOP_RECHARGE_RETURN_COST("sre_rc","sre","SRE","店铺充值返现",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.IN),
    SHOP_RECHARGE_FIRST_RETURN_COST("sre_frc","sre","SRE","店铺首次充值返现",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.IN),
    SHOP_WITHDRAWAL_APPLY_FOR("swl_af","swl","SWL","店铺提现申请",AccountTypeEnum.SHOP_ACCOUNT,AccountTypeEnum.ALLOCATION_ACCOUNT,AmountIconEnum.OUT),
    SHOP_WITHDRAWAL_CANCEL("swl_cl","swl","SWL","店铺提现取消",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.OUT),
    SHOP_WITHDRAWAL("swl","swl","SWL","店铺提现",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.R_W_ACCOUNT,AmountIconEnum.OUT),
    GIFT("gf","gf","GF","赠送用户",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    DEDUCT("de","de","DE","扣款用户",AccountTypeEnum.USER_ACCOUNT,AccountTypeEnum.TOTAL_ACCOUNT,AmountIconEnum.OUT),

    SHOP_GIFT("sgf","sgf","SGF","赠送店铺",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.IN),
    SHOP_DEDUCT("sde","sde","SDE","扣款店铺",AccountTypeEnum.SHOP_ACCOUNT,AccountTypeEnum.TOTAL_ACCOUNT,AmountIconEnum.OUT),

    PURCHASE("pu","pu","PU","采购货款",AccountTypeEnum.SHOP_ACCOUNT,AccountTypeEnum.TOTAL_ACCOUNT,AmountIconEnum.JH),
    REFUND("rf","rf","RF","采购退款",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.IN),

    USER_ORDER("yh","yh","YH","用户订单",AccountTypeEnum.USER_ACCOUNT,AccountTypeEnum.ALLOCATION_ACCOUNT,AmountIconEnum.OUT),
    USER_ORDER_RETURN_BEFORE("yh_rb","yh","YH","用户订单退款-结算前",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    USER_ORDER_RETURN_AFTER("yh_ra","yh","YH","用户订单退款-结算后",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),

    ORDER_COST("yh_ct","yh","YH","订单成本",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.JH),
    ORDER_PROFIT("yh_op","yh","YH","订单盈利",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.IN),
    ORDER_PROFIT_SUPERIOR_GET("yh_sg","yh","YH","订单上级分成",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.IN),
    ORDER_PROFIT_ANCHOR_GET("yh_ag","yh","YH","订单主播分成",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    ORDER_PROFIT_PLATFORM_GET("yh_pg","yh","YH","订单平台分成",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.TOTAL_ACCOUNT,AmountIconEnum.IN),
    ORDER_SUBSIDY_PROFIT_FREEZE("yh_spf","yh","YH","订单补贴冻结",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.ALLOCATION_ACCOUNT,AmountIconEnum.IN),
    ORDER_SUBSIDY_PROFIT("yh_sp","yh","YH","订单补贴",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.IN),

    LIVE_GOLD_COIN("gc","gc","GC","金币购买",AccountTypeEnum.USER_ACCOUNT,AccountTypeEnum.TOTAL_ACCOUNT,AmountIconEnum.DH),

    PRODUCT_INVESTMENT("pt","pt","PT","理财产品投资",AccountTypeEnum.USER_ACCOUNT,AccountTypeEnum.ALLOCATION_ACCOUNT,AmountIconEnum.OUT),
    PRODUCT_INVESTMENT_PROFIT_OUT("pt_po","pt","PT","平台理财产品利润发放",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.ALLOCATION_ACCOUNT,AmountIconEnum.OUT),
    PRODUCT_INVESTMENT_PRINCIPAL_RETURN("pt_pr","pt","PT","理财产品本金退返",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    PRODUCT_INVESTMENT_PROFIT_IN("pt_pi","pt","PT","理财产品收益",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    PRODUCT_INVESTMENT_SUPERIOR_PROFIT_IN("pt_spi","pt","PT","理财产品上级收益",AccountTypeEnum.ALLOCATION_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),

    LIVE_GIFT_ANCHOR_GET("lg_ag","lg","LG","直播礼物收益主播分成",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    FINANCIAL_OFFLINE_USER_GET("fu","fu","FU","线下理财用户收益",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    FINANCIAL_OFFLINE_USER_SUPERIOR_GET("fu_sg","fu","FU","线下理财用户上级收益",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),

    SHOP_DATA_PACKAGE("sdp","sdp","SDP","店铺流量购买",AccountTypeEnum.SHOP_ACCOUNT,AccountTypeEnum.TOTAL_ACCOUNT,AmountIconEnum.OUT),

    INVITE_REWARDS("ir","ir","IR","邀请奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),


    LIVES_BASIC_SALARY("lv_bs","lv","LV","直播底薪",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    LIVES_GIFT_GET("lv_gg","lv","LV","直播礼物收益",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),

    VIDEO_REWARD("vr","vr","VR","视频奖励分佣",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    SELF_VIDEO_REWARD("svr","svr","SVR","视频奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    SHOP_EARNEST_MONEY("em","em","EM","保证金",AccountTypeEnum.USER_ACCOUNT,AccountTypeEnum.SHOP_EARNEST_MONEY_ACCOUNT,AmountIconEnum.OUT),
    RETURN_SHOP_EARNEST_MONEY("rem","em","REM","退还保证金",AccountTypeEnum.SHOP_EARNEST_MONEY_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),

    EARNEST_MONEY_DEDUCTION_GOODS_PAY("pu_em","pu","PU","保证金抵扣货款",AccountTypeEnum.SHOP_EARNEST_MONEY_ACCOUNT,AccountTypeEnum.TOTAL_ACCOUNT,AmountIconEnum.OUT),
    DEDUCTION_GOODS_PAY_RETURN_EARNEST_MONEY("pu_rem","pu","PU","货款退回保证金",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.SHOP_EARNEST_MONEY_ACCOUNT,AmountIconEnum.IN),

    SHOP_UPGRADE_REWARD("sur","sur","SUR","店铺升级奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.IN),
    SHOP_REGISTER_REWARD("srr","srr","SRR","店铺注册奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.IN),
    SHOP_INVITE_REWARD("sir","sir","SIR","店铺邀请奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.SHOP_ACCOUNT,AmountIconEnum.IN),
    CUMULATIVE_INCOME_BONUS("cib","cib","CIB","累计收益奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    FOLLOWER_BONUS("fb","fb","FB","粉丝量奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    TIME_BONUS_FOR_FIRST_LIVE_BROADCAST("flt","flt","FLT","首次直播时长奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    EARNINGS_DAY_RANKING_REWARDS("edrr","edrr","EDRR","收益日排名奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    EARNINGS_MONTHLY_RANK_BONUS("emrb","emrb","EMRB","收益月排名奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    WATCH_LIVE_TIME_BONUS("wrtb","wrtb","WRTB","观看直播时长奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),

    USER_LEVEL_UPGRADE_REWARDS("ulur","ulur","ULUR","用户升级奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    USER_RECHARGE_FIRST_RETURN_COST("urfrc","urfrc","URFRC","用户首次充值返现",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    USER_REGISTER_REWARD("urr","urr","URR","用户注册奖励",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    USER_RECHARGE_RETURN_COST("urrc","urrc","URRC","用户充值返现",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    USER_SEND_OUT_GIFT_RETURN_COST("usogrc","usogrc","USOGRC","送礼奖励返现",AccountTypeEnum.TOTAL_ACCOUNT,AccountTypeEnum.USER_ACCOUNT,AmountIconEnum.IN),
    ;

    /**
     * code
     */
    private String code;
    /**
     * 类型
     */
    private String type;


    /**
     * 业务号前缀
     */
    private String prefix;

    /**
     * 描述
     */
    private String desc;

    /**
     * 出帐账户类型
     */
    private AccountTypeEnum out;
    /**
     * 进账账户类型
     */
    private AccountTypeEnum in;

    private AmountIconEnum icon;
    AccountBusinessTypeEnum(String code,String type, String prefix, String desc,AccountTypeEnum out,AccountTypeEnum in,AmountIconEnum icon) {
        this.code=code;
        this.type = type;
        this.prefix =prefix;
        this.desc = desc;
        this.out=out;
        this.in=in;
        this.icon=icon;
    }

    public String getCode() {
        return code;
    }

    public String getType() {
        return type;
    }


    public String getPrefix() {
        return prefix;
    }

    public String getDesc() {
        return desc;
    }

    public AccountTypeEnum getOut() {
        return out;
    }

    public AccountTypeEnum getIn() {
        return in;
    }

    public AmountIconEnum getIcon() {
        return icon;
    }

    /**
     * 店铺收益
     * @return
     */
    public static List<String> getShopIncomeCode(){
        List<String> codeList = new ArrayList<>();
        codeList.add(ORDER_PROFIT.code);
        codeList.add(ORDER_SUBSIDY_PROFIT.code);
        codeList.add(ORDER_PROFIT_SUPERIOR_GET.code);
        return codeList;
    }

    /**
     * 用户收益
     * @return
     */
    public static List<String> getUserIncomeCode(){
        List<String> codeList = new ArrayList<>();
        codeList.add(INVITE_REWARDS.code);
        codeList.add(FINANCIAL_OFFLINE_USER_SUPERIOR_GET.code);
        codeList.add(FINANCIAL_OFFLINE_USER_GET.code);
        codeList.add(LIVE_GIFT_ANCHOR_GET.code);
        codeList.add(PRODUCT_INVESTMENT_SUPERIOR_PROFIT_IN.code);
        codeList.add(PRODUCT_INVESTMENT_PROFIT_IN.code);
        codeList.add(ORDER_PROFIT_ANCHOR_GET.code);
        codeList.add(LIVES_GIFT_GET.code);
        codeList.add(VIDEO_REWARD.code);
        codeList.add(SELF_VIDEO_REWARD.code);
        return codeList;
    }



    /**
     * 店铺佣金
     * @return
     */
    public static List<String> getShopCommissionCode(){
        List<String> codeList = new ArrayList<>();
        codeList.add(ORDER_PROFIT_SUPERIOR_GET.code);
        return codeList;
    }

    /**
     * 用户佣金
     * @return
     */
    public static List<String> getUserCommissionCode(){
        List<String> codeList = new ArrayList<>();
        codeList.add(PRODUCT_INVESTMENT_SUPERIOR_PROFIT_IN.code);
        codeList.add(FINANCIAL_OFFLINE_USER_SUPERIOR_GET.code);
        codeList.add(VIDEO_REWARD.code);
        return codeList;
    }
    public static AmountIconEnum getIcon(String code){
        for (AccountBusinessTypeEnum busType:AccountBusinessTypeEnum.values()) {
            if (Objects.equals(busType.getCode(),code)){
                return busType.getIcon();
            }
        }
        return AmountIconEnum.IN;
    }

    public static AccountBusinessTypeEnum getAccountBusinessType(String code){
        for (AccountBusinessTypeEnum busType:AccountBusinessTypeEnum.values()) {
            if (Objects.equals(busType.getCode(),code)){
                return busType;
            }
        }
        return null;
    }

    public static void main(String[] args) {
        AtomicInteger i= new AtomicInteger(1);
        Arrays.stream(AccountBusinessTypeEnum.values()).forEach(e->{
            //System.out.println(i+","+e.getDesc()+","+e.getCode()+",bus_type_detail");
            System.out.println(e.getCode().toUpperCase()+"("+i+",\""+e.getCode()+"\"),");
            i.getAndIncrement();
        });
    }
}

